import { BookingDataRes } from "@/components/booking-record/types";
import { create } from "zustand";

export interface VehicleList {
  approvalStatus?: string;
  vehType?: vehType;
  lpnNo?: string;
  octopus?: string;
  dppp?: string;
  authLetter?: string;
}

export interface ParkList {
  chineseName?: string;
  dpppPrice?: vehType;
  englishName?: string;
  parkId?: string;
  price?: string;
  tariffId?: string;
  shortForm?: string;
}

// 定义状态类型
interface ParkStoreState {
  parkId: string;
  vehType: string;
  pymPrice: string;
  startDate: string;
  dpppPrice: string;
  price: string;
  period: number;
  vehicleList: VehicleList;
  parkList: ParkList;
  bookingDataRes?: BookingDataRes;
  setParkId: (id: string) => void;
  setVehType: (type: string) => void;
  setPymPrice: (price: string) => void;
  setStartDate: (date: string) => void;
  setPrice: (price: string) => void;
  setDpppPrice: (dpppPrice: string) => void;
  setPeriod: (period: number) => void;
  setVehicleList: (vehicleList: VehicleList) => void;
  setParkList: (parkList: ParkList) => void;
  setBookingDataRes: (bookingDataRes: BookingDataRes) => void;
}

const useParkStore = create<ParkStoreState>((set) => ({
  parkId: "",
  vehType: "PRIVATE_CAR",
  pymPrice: "",
  startDate: "",
  dpppPrice: "",
  price: "",
  period: 0,
  vehicleList: {},
  parkList: {},
  bookingDataRes: undefined,
  setParkId: (id) => set({ parkId: id }),
  setVehType: (type) => set({ vehType: type }),
  setPymPrice: (price) => set({ pymPrice: price }),
  setStartDate: (date) => set({ startDate: date }),
  setPrice: (price) => set({ price }),
  setDpppPrice: (dpppPrice) => set({ dpppPrice }),
  setPeriod: (period) => set({ period }),
  setVehicleList: (vehicleList) => set({ vehicleList }),
  setParkList: (parkList) => set({ parkList }),
  setBookingDataRes: (bookingDataRes) => set({ bookingDataRes }),
}));

// // 添加 getState 方法
// useParkStore.getState = useParkStore;

export default useParkStore;
